package com.gjy.statemachine;

import com.gjy.statemachine.event.Events;
import com.gjy.statemachine.state.States;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.statemachine.StateMachine;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-07-02 11:04:39
 */
@SpringBootApplication
public class StateMachineApp implements CommandLineRunner {

    private static final Logger log = LoggerFactory.getLogger(StateMachineApp.class);

    @Resource
    private StateMachine<States, Events> stateMachineSimple;

    public static void main(String[] args) {
        SpringApplication.run(StateMachineApp.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        log.info("command line runner: {}", Arrays.toString(args));
        stateMachineSimple.sendEvent(Events.E1);
        stateMachineSimple.sendEvent(Events.E1);
    }

}
